<%@page import="com.shsh.safemanage.model.User"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.Equipment"%>
<%@page import="com.shsh.safemanage.dao.EquipmentDao"%>
<%@page import="com.shsh.safemanage.util.Util"%>
<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.dao.DepartmentDao"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.util.Constants"%>

<%
String equipName = request.getParameter(Constants.REQUEST_PARAMETER_EQUIPMENT_NAME);
if (equipName == null) {
	equipName = "";
}
equipName = Util.isoToUTF8(equipName);

String pageNumStr = request.getParameter(Constants.REQUEST_PARAMETER_PAGE_NUM);
int pageNum = 1;
try {
	pageNum = Integer.parseInt(pageNumStr);
} catch (Exception e) {
}

String chooseType = request.getParameter("chooseType");

Department1 problemDepart1 = (Department1) session.getAttribute(Constants.SESSION_PROBLEM_DEPARTMENT1);
User theUser = (User) session.getAttribute(Constants.SESSION_USER);

Long theDepartID = null;
if (problemDepart1 != null) {
	theDepartID = problemDepart1.getId();
} else {
	if (theUser != null) {
		theDepartID = theUser.getDepartment1ID();
	}
}
EquipmentDao equipmentDao = DaoCreator.createEquipmentDao();
List<Equipment> equipList = equipmentDao.getEquipmentList(equipName, theDepartID, pageNum, 20);
%>
<%
if (equipList.size() > 0) {
%>
<table width="750" border="1" cellpadding="0"
		cellspacing="0">
	<%
	for (int i = 0; i < 100; i++) {
	%>
	<tr>
		<%
		for (int j = 0; j < 4; j++) {
			int index = i * 4 + j;
			if (index >= equipList.size()) {
				break;
			}
			Equipment equipment = equipList.get(index);
		%>
		<td align="center"><%=equipment.getEquipName()%>
		<%
		if (chooseType == null || !chooseType.equals("2")) {
		%>
		<a href="javascript:" onclick="chooseMappingEquipment1(<%=equipment.getId()%>,'1')">装置长</a>
		<a href="javascript:" onclick="chooseMappingEquipment1(<%=equipment.getId()%>,'0')">非装置长</a> 
		<%
		} else {
		%>
		<a href="javascript:" onclick="chooseMappingEquipment1(<%=equipment.getId()%>,'0')">选择</a>
		<%
		}
		%>
		</td>
		<%
		}
		%>
	</tr>
	<%
	}
	%>
</table>
<%
}
%>
